package com.apes.hr.base.model;

import com.alibaba.fastjson.annotation.JSONField;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.Name;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.util.ApesConst;
import com.apes.framework.util.DateUtil;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import java.util.Date;

/**
 * 功能：人员工作经历
 * @author HuJianlin
 * @create 2018-04-25 15:11
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = EmployeeWorkHistory.CONST_TABLE_NAME)
public class EmployeeWorkHistory extends Model {
    public static final String CONST_TABLE_NAME = "hr_Employee_Work_History";

    @Id
    @Column(name = "id")
    @ApesGenerator(code = CONST_TABLE_NAME, name = "人员工作经历")
    @Comment("编码")
    private long id; //编码

    @ManyToOne
    @JoinColumn(name = "employee_id", referencedColumnName="id")
    @Comment("员工")
    private Employee employee; //员工

    @ManyToOne
    @JoinColumn(name = "talent_pool_id", referencedColumnName="id")
    @Comment("人才储备")
    private TalentPool talentPool; //人才储备

    @Name
    @Column(name = "work_unit", length = 32)
    @Comment("工作单位")
    private String workUnit; //工作单位

    @Column(name = "branch",  length = 32)
    @Comment("部门")
    private String branch; //部门

    @Column(name = "jobs", length = 16)
    @Comment("职务")
    private String jobs; //职务

    @JSONField(format = DateUtil.SHOW_DATETIME_FORMAT)
    @Temporal(TemporalType.DATE)
    @Column(name = "start_date")
    @Comment("开始日期")
    private Date startDate; //开始日期

    @JSONField(format = DateUtil.SHOW_DATETIME_FORMAT)
    @Temporal(TemporalType.DATE)
    @Column(name = "end_date")
    @Comment("结束日期")
    private Date endDate; //结束日期

    @Column(name = "base_salary",  columnDefinition = ApesConst.FIELD_MONEY_16_4)
    @Comment("底薪")
    private double baseSalary;  //底薪

    @Column(name = "commission",  columnDefinition = ApesConst.FIELD_MONEY_16_4)
    @Comment("提成")
    private double commission;  //提成

    @Column(name = "quit_cause", length = 32)
    @Comment("离职原因")
    private String quitCause;  //离职原因

    @Column(name = "reterence", length = 32)
    @Comment("证明人")
    private String reterence; //证明人

    @Column(name = "reterence_jobs",  length = 32)
    @Comment("证明人职务")
    private String reterenceJobs; //证明人职务

    @Column(name = "reterence_phone", length = 32)
    @Comment("证明人电话")
    private String reterencePhone; //证明人电话

}
